using System.Collections;
using UnityEngine;

public class ButtonFlicker : MonoBehaviour
{
	public float flickerTime = 1f;

	private Vector3 scale;

	private void Awake()
	{
		scale = base.transform.localScale;
	}

	private void OnEnable()
	{
		StartCoroutine(Flicker());
	}

	private IEnumerator Flicker()
	{
		while (true)
		{
			for (float time2 = 0f; time2 < flickerTime; time2 += Time.deltaTime)
			{
				base.transform.localScale = scale * (1f + 0.5f * time2 / flickerTime);
				yield return null;
			}
			yield return new WaitForSeconds(0.2f);
			for (float time = 0f; time < flickerTime; time += Time.deltaTime)
			{
				base.transform.localScale = scale * (1.5f - 0.5f * time / flickerTime);
				yield return null;
			}
			yield return new WaitForSeconds(1f);
		}
	}

	private void OnDisable()
	{
		StopAllCoroutines();
		base.transform.localScale = scale;
	}
}
